﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="jquery.js"></script>
</head>
<body>
    <button id="submit">submit</button>
    <p id="result" style="color:orangered;font-weight:bold;font-size:24px;"></p>
</body>
</html>
<script src="signalr.js"></script>
<!--<script src="./index.js"></script>-->
<script>
    let token = "K1F6GBer8uePfE/5s+meqliGJCS47fzAUntTs59xT74GNsJv+XKo4WBPVWUWBGC4QaLw3GGACkPwMO2Q20uPbVtzeSVpCbsBKO2U7fNTMjEvHotL1AdgiI1qdymtbymSDIhxM5X54xWktxUu8tLT99U1V8NzJqWCeV4OMKrImcclH1gfdGXllEs9qydqGK7HHdpxfQ0tB/zrzwKhkir2OC6XgkFjyukBVtFV4Dt/MMDnxWZBJPChrYfSFhp7pAOO4k2XMl1HEp3+4FWfYTAu3n12wepmO+GruJ3ZbxWcp5h4nC535dPGx1uXrdK/HhLUr4OlVzoTwA8nzIj6mr65/FRj+dCebF1Qq+WEZRZmCiiog6fmovRSl+Uq+2iE8IQU31F6CHtIfA/kgrX5ijIspGeihKwlJMLVuoREDHEJtrajfpNlD4e5OPUrAHxr6wuTQUymvZCdqJUWotiNvgRCAGCJqpYVh6J1kGUcMnjEZTZf8SDCzsVU807CNtgDsHnZVqwJYX1JTfTb/spkQbRfnAuXbp8cU1CVKzuysidzDqHYApPc9LQNeRwSkpVuGWdnEslw9bwX5fDQbRjCkothf0uUMD2e06sWRAEjMMCcVBCb7WoPCGE1UuW7HlBULgCCXdc0/h5xM5Oa+Xjgj8vGGCCd9oyxjaD4atQM1+QcBaMe/STKZ/QlXkrg/kI7VIuRvrgYFWAPfpWmJ6Mn7ksKQ6+Lu8JAV7WXpnXtfD6UmrmZX5IPvwlU2FbmsJuGNvoOwOknKfZgJ8HC/5PvEDIQ66fjNlj+5M3Vu3tY3bgNbldcv9F8hRWSaaCVXIQJfvKDpAUus/1zkTJDnZMLO5YROZpNynHBHOuOC4s4btiBP+A=";
    let connection = null;
    setupConnection = () => {
        connection = new signalR.HubConnectionBuilder()
            .withUrl("/signalr", { accessTokenFactory: () => token })
            .build();
        connection.start().catch(err => console.error(connection));
    }
    setupConnection();
    console.log(connection);
    document.getElementById("submit").addEventListener("click", e => {
        connection.invoke("SendMessage").catch(
            err => console.log(err)
        )
    });

    connection.on("getMessage", (update) => {
        const resultdiv = document.getElementById("result");
        resultdiv.innerHTML = update;
    });
</script>